package com.woniuxy.hrp.provider;

import com.woniuxy.hrp.entity.OrderUser;
import org.apache.ibatis.jdbc.SQL;

/**
 * @Description：用于产生动态查询、修改的sql语句
 * @Author：曹杰克
 * @CreateTime：2022/8/29 19:39
 */
public class OrderUserMapperSqlProvider {
    public static String updateOrderUser(OrderUser orderUser) {
        String sql = new SQL() {
            {
                UPDATE("hrp_orderuser");
                if (orderUser.getName() != null && orderUser.getName() != "") {
                    SET("name=#{name}");
                }
                if (orderUser.getAge() != 0) {
                    SET("age=#{age}");
                }
                if (orderUser.getPhone() != null && orderUser.getPhone() != "") {
                    SET("phone=#{phone}");
                }
                if (orderUser.getAddress() != null && orderUser.getAddress() != "") {
                    SET("address=#{address}");
                }
                if (orderUser.getGender() != null && orderUser.getGender() != "") {
                    SET("gender=#{gender}");
                }
                if (orderUser.getDef() != null && orderUser.getDef() != "") {
                    SET("def=#{def}");
                }
                WHERE("id=#{id}");
            }
        }.toString();
        return sql;
    }
}
